/*
 * Copyright (c) 2022. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.pobing.service.impl;

import com.pobing.grpc.lib.hello.HelloResponse;
import com.pobing.grpc.lib.move.MoveRequest;
import com.pobing.grpc.lib.move.MoveResponse;
import com.pobing.grpc.lib.move.MoveServiceGrpc;
import com.pobing.service.MoveService;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;

/**
 * @author xfworld
 * @since create on 2022-05-17.
 **/
@GrpcService
public class MoveServiceImpl extends MoveServiceGrpc.MoveServiceImplBase implements MoveService {


    @Override
    public void sayMove(MoveRequest moveRequest, StreamObserver<MoveResponse> moveResponseStreamObserver) {
        String name = moveRequest.getName();
        System.out.println("received client name is " + name);
        MoveResponse response = MoveResponse.newBuilder().setCode("1111").setMessage("move "+ name).build();
        moveResponseStreamObserver.onNext(response);
        moveResponseStreamObserver.onCompleted();
    }
}
